<!--
 * @Author: 杨三炮
 * @Date: 2021-12-03 17:28:29
 * @LastEditors: 杨三炮
 * @LastEditTime: 2021-12-04 12:07:29
 * @FilePath: \daka\src\views\Leave.vue
-->
<template>
  <div>
    <van-tabs v-model="active" animated>
      <van-tab title="请假记录" name="LeaveRecord">
        <LeaveRecord ref="LeaveRecord" />
      </van-tab>
      <van-tab title="请假" name="leaves">
        <leaves @setActive="setActive" />
      </van-tab>
    </van-tabs>
  </div>
</template>

<script>
import LeaveRecord from '../components/LeaveRecord.vue'
import Leaves from '../components/Leaves.vue'
export default {
  name: 'leave',
  data () {
    return {
      active: 'LeaveRecord',
    }
  },
  components: { LeaveRecord, Leaves },
  created () {
    const userinfo = JSON.parse(localStorage.userInfo)
    //token存储到vuex中
    this.$store.dispatch('setAuthenticated', userinfo)
    this.$store.dispatch('setUser', userinfo)
  },
  methods: {
    setActive (str) {
      this.$refs.LeaveRecord.getLeave()
      this.active = str
    }
  },

}
</script>

<style scoped>
</style>